import Vue from 'vue'
import Cookies from 'js-cookie'//引入Cookies插件
import VueI18n from 'vue-i18n'

let lang = Cookies.get('language') || 'zh_CN'
import i18nEn from '@/i18n/en'
import i18nZh from '@/i18n/zh'
import zhCN from 'vxe-table/lib/locale/lang/zh-CN'
import enUS from 'vxe-table/lib/locale/lang/en-US'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
const messages = {
  zh_CN: {
    ...i18nZh,
    ...zhCN,
    ...zhLocale
  },
  en_US: {
    ...i18nEn,
    ...enUS,
    ...enLocale
  }
}

Vue.use(VueI18n)


const i18n = new VueI18n({
  locale: lang,
  fallbackLocale: 'zh_CN',//没有英文的时候默认中文语言
  silentFallbackWarn: true,//抑制警告
  //this.$i18n.locale // 通过切换locale的值来实现语言切换
  messages,
})


export default i18n